﻿using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using System.Diagnostics;
using System.Windows.Forms;


namespace GLEED2D
{
    [DebuggerDisplay("Name: {Name}, Address: {&Name}")]
    public partial class Level : IUndoable
    {

        public void add()
        {
        }

        public void remove()
        {
        }

        public IUndoable cloneforundo()
        {
            selecteditems = "";
            foreach (Item i in Editor.Instance.SelectedItems)
				selecteditems += i.Name + ";";

            Level result = (Level)this.MemberwiseClone();
			result.Items = new List<Item>(Items);
			for (int i = 0; i < result.Items.Count; i++)
            {
				result.Items[i] = result.Items[i].clone();
				result.Items[i].Parent = null;
            }
            return (IUndoable)result;
        }

        public void makelike(IUndoable other)
        {
            /*Layer l2 = (Layer)other;
            Items = l2.Items;
            treenode.Nodes.Clear();
            foreach (Item i in Items)
            {
                Editor.Instance.addItem(i);
            }*/


            Level l2 = (Level)other;
			Items = l2.Items;
            treenode.Nodes.Clear();
			foreach (Item item in Items)
            {
                Editor.Instance.level.Items.Add(item);
                //TODO add all items
            }
        }

        public string getName()
        {
            return Name;
        }

        public void setName(string name)
        {
            Name = name;
            treenode.Text = name;
        }

    }
}
